package cn.buddha.jesj.list;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName ListTest
 * @Author 友野浩二
 * @Date 2019/12/9 16:22
 * @Description list集合测试类
 * @Version 1.0
 */
public class ListTest {

    public static void main(String[] args) {
        List<Human> humanList = new ArrayList<>(3);
        humanList.add(new Human("人民", "西雅图", "3"));
        humanList.add(new Human("政客", "华盛顿", "1"));
        humanList.add(new Human("资本家", "纽约", "2"));
        humanList.add(new Human("呵呵", "额", null));

        System.err.println("排序前: " + humanList);

        Collections.sort(humanList);

        System.err.println("排序后: " + humanList);

        // 过滤 等级为 1 的 数据
        List<Human> collect =
                humanList.stream()
                        .filter(human -> "1".equals(human.getGrades()))
                        .collect(Collectors.toList());
        System.err.println(collect);
    }

}
